package cn.ito.zjgsu.utils.impl;

import java.util.Random;

import org.springframework.stereotype.Component;

import cn.ito.zjgsu.utils.RandomStringUtil;

@Component
public class SimpleRadomStringUtil implements RandomStringUtil {

	private int DEFAULT_SIZE = 6;

	@Override
	public String getRandomString() {

		String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
		Random random = new Random();
		StringBuffer sb = new StringBuffer();

		for (int i = 0; i < DEFAULT_SIZE; ++i) {
			int number = random.nextInt(62);// [0,62)

			sb.append(str.charAt(number));
		}
		return sb.toString();

	}

}
